package com.molichuxing.gateway.bff.user.services.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.molichuxing.gateway.bff.user.convertor.Convert;
import com.molichuxing.gateway.bff.user.entity.response.UserVo;
import com.molichuxing.gateway.bff.user.services.UserBffService;
import com.molichuxing.services.business.dto.response.OrderBizDto;
import com.molichuxing.services.business.dto.response.UserDetailBizDto;
import com.molichuxing.services.business.service.OrderBizService;
import com.molichuxing.services.business.service.UserBizService;

/**
 * 
 * @author liyg
 * 2019-08-16
 * 用户bff服务实现类
 * 
 */
@Service("userBffService")
public class UserBffServiceImpl implements UserBffService{

	@Resource
	private UserBizService userBizService;
	
	@Resource
	private OrderBizService orderBizService;
	
	
	/**
	 * 根据订单编号获取用户信息 (包括身份证基本信息)
	 * @param orderCode
	 * @return 
	 */
	@Override
	public UserVo getUserByOrderCode(Long orderCode) {
		
		OrderBizDto order = orderBizService.getOrder(orderCode);
		if(null == order) {
			return null;
		}
		
		UserDetailBizDto userDetailBizDto=userBizService.getUserDetail(order.getUserId());
		UserVo userVo = Convert.toUserVo(userDetailBizDto);
		
		return userVo;
	}
	
}
